﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace evepctlib
{
    public class Ore
    {
        private readonly OreName _nom;
        
        public readonly string Nom;
        public readonly OreType Type;
        public double Prix;
        public readonly int Id;
        
        /// <summary>
        /// Création d'un minerai
        /// </summary>
        /// <param name="nom">nom du minerai</param>
        /// <param name="type">type de minerai</param>
        /// <param name="prix">prix du minerai (0 si inconnu)</param>
        public Ore(OreName nom, OreType type, double prix)
        {
            Type = type;
            switch(type)
            {
                case OreType.Normal:
                    Prix = prix;
                    break;
                case OreType.PlusCinq:
                    Prix = prix + (0.05*prix);
                    break;
                case OreType.PlusDix:
                    Prix = prix + (0.1*prix);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("type");
            }

            _nom = nom;
            Id = GetMineralId(nom);
            Nom = GetName(nom, type);
            Prix = prix;
            
        }

        /// <summary>
        /// Mets à jour le prix d'un minerai
        /// Attention, le prix est mis à l'échelle en fonction de sa densité
        /// </summary>
        /// <param name="nouveauPrix">nouveau prix du minerai</param>
        /// <returns>Prix à l'échelle en fonction de sa densité</returns>
        public double ChangePrix(double nouveauPrix)
        {
            switch (Type)
            {
                case OreType.Normal:
                    break;
                case OreType.PlusCinq:
                    nouveauPrix = nouveauPrix + (0.05 * nouveauPrix);
                    break;
                case OreType.PlusDix:
                    nouveauPrix = nouveauPrix + (0.1 * nouveauPrix);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("type");
            }
            Prix = nouveauPrix;
            return Prix;
        }


        public override string ToString()
        {
            return Nom;
        }

        public static int GetMineralId(OreName m)
        {
            switch (m)
            {
                case OreName.Veldspar:
                    return 1230;
                case OreName.Scordite:
                    return 1228;
                case OreName.Pyroxeres:
                    return 1224;
                case OreName.Plagioclase:
                    return 18;
                case OreName.Omber:
                    return 1227;
                case OreName.Kernite:
                    return 20;
                case OreName.Jaspet:
                    return 1226;
                case OreName.Hemorphite:
                    return 1231;
                case OreName.Hedbergite:
                    return 21;
                case OreName.Gneiss:
                    return 1229;
                case OreName.DarkOchre:
                    return 1232;
                case OreName.Spodumain:
                    return 19;
                case OreName.Crokite:
                    return 1225;
                case OreName.Bistot:
                    return 1223;
                case OreName.Arkonor:
                    return 22;
                case OreName.Mercoxit:
                    return 11396;
                default:
                    throw new ArgumentOutOfRangeException("m");
            }
        }

        public static string GetName(OreName nom, OreType type)
        {
            string nomString;
            string nomType = String.Empty;
            
            switch(nom)
            {
                case OreName.Veldspar:
                    nomString = "Veldspar";
                    if (type == OreType.PlusCinq) nomType = "Concentrated";
                    if (type == OreType.PlusDix) nomType = "Dense";
                    break;
                case OreName.Scordite:
                    nomString = "Scordite";
                    break;
                case OreName.Pyroxeres:
                    nomString = "Pyroxeres";
                    break;
                case OreName.Plagioclase:
                    nomString = "Plagioclase";
                    break;
                case OreName.Omber:
                    nomString = "Omber";
                    break;
                case OreName.Kernite:
                    nomString = "Kernite";
                    break;
                case OreName.Jaspet:
                    nomString = "Jaspet";
                    break;
                case OreName.Hemorphite:
                    nomString = "Hemorphite";
                    break;
                case OreName.Hedbergite:
                    nomString = "Hedbergite";
                    break;
                case OreName.Gneiss:
                    nomString = "Gneiss";
                    break;
                case OreName.DarkOchre:
                    nomString = "Dark Ochre";
                    break;
                case OreName.Spodumain:
                    nomString = "Spodumain";
                    break;
                case OreName.Crokite:
                    nomString = "Crokite";
                    break;
                case OreName.Bistot:
                    nomString = "Bistot";
                    break;
                case OreName.Arkonor:
                    nomString = "Arknor";
                    break;
                case OreName.Mercoxit:
                    nomString = "Mercoxit";
                    break;
                default:
                    throw new ArgumentOutOfRangeException("nom");
            }
            return nomType != string.Empty ? nomType + " " + nomString : nomString;
        }

    }


    public enum OreName
    {
        Veldspar,
        Scordite,
        Pyroxeres,
        Plagioclase,
        Omber,
        Kernite,
        Jaspet,
        Hemorphite,
        Hedbergite,
        Gneiss,
        DarkOchre,
        Spodumain,
        Crokite,
        Bistot,
        Arkonor,
        Mercoxit,
    }



    public enum OreType
    {
        Normal,
        PlusCinq,
        PlusDix
    }

}
